import yaml
import os
from utils.log_utils import log

class FileUtil:
    @staticmethod
    def read_yaml(file_path):
        """读取yaml文件（相对路径基于项目根目录）"""
        full_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), file_path)
        try:
            with open(full_path, "r", encoding="utf-8") as f:
                return yaml.safe_load(f)
        except Exception as e:
            log.error(f"读取文件{full_path}失败：{e}")
            raise